package com.truthbean.jeetb.utils.web.invoker;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.net.ServerSocket;

//StopMapPort
public class SmpInvoker extends DefaultInvoker {
    public boolean doAfter() {
        return true;
    }

    public boolean doBefore() {
        return true;
    }

    public void invoke(HttpServletRequest request, HttpServletResponse response, HttpSession JSession) throws Exception {
        try {
            Object obj = JSession.getAttribute(PORT_MAP);
            if (obj != null) {
                ServerSocket server = (ServerSocket) JSession.getAttribute(PORT_MAP);
                server.close();
            }
            JSession.setAttribute("done", "Stop Success!");
            ins.get("vmp").invoke(request, response, JSession);
        } catch (Exception e) {
            e.printStackTrace();
            throw e;
        }
    }
}

